package com.kingdee.pda.priority;

import android.content.Context;

import com.example.basecommon.http.MyObserver;
import com.example.basecommon.http.RxHelper;
import com.example.basecommon.http.rxjava.BaseResponse;
import com.example.basecommon.http.rxjava.HttpUtils;
import com.example.basecommon.utils.ConstantUtil;
import com.kingdee.pda.Api;
import com.kingdee.pda.entity.PriorityBean;

import java.util.HashMap;

public class PriorityPresenter implements PriorityContract.IPriorityPresenter{
    Context context;
    PriorityContract.IPriorityView view;


    public PriorityPresenter(Context context, PriorityContract.IPriorityView view) {
        this.context = context;
        this.view = view;
    }

    @Override
    public void getPriorityList(String uid) {
        MyObserver<PriorityBean.Data> myObserver = new MyObserver<PriorityBean.Data>(context) {
            @Override
            public void onSuccess(BaseResponse<PriorityBean.Data> result) {
                view.getPrioritySuccess(result.data);
            }

            @Override
            public void onFailure(BaseResponse<PriorityBean.Data> result, String msg) {
                view.getPriorityFailed(msg);
            }
        };

        HttpUtils.request(Api.class)
                .checkPriority(ConstantUtil.CHECK_PRIORITY)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(myObserver);
    }
}
